package com.dingding.service.user.core.dao.impl;

import java.util.List;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.dao.impl.BaseDaoImpl;
import com.dingding.common.core.beans.UserCoupon;
import com.dingding.service.user.core.dao.IUserCouponDao;

/**
 * @ClassName: UserCouponDaoImpl
 * @Description: 用户优惠券信息接口实现
 * @author chenwei
 * @date 2016年6月5日 下午5:27:31
 * @version 叮叮搭车V2.2
 */
@Component("userCouponDao")
public class UserCouponDaoImpl extends BaseDaoImpl<UserCoupon> implements IUserCouponDao {

	/**
	 * 
	 * @Title: getUserCouponList @Description: 获取用户优惠券信息 @param userId
	 * 用户Id @author chenwei @return List<UserCoupon> 当前用户id下面所有能使用的优惠券 @throws
	 */
	@Override
	@Transactional(readOnly = true)
	public List<UserCoupon> getUserCouponList(String userId) {

		List<UserCoupon> userCouponsList = null;

		Criterion criterion = Restrictions.and(Restrictions.eq("loginId", userId), Restrictions.eq("couponStatus", 2), Restrictions.eq("couponType", 2));

		try {
			userCouponsList = super.queryCriteriaList(criterion);
		} catch (Exception e) {
			log.error("获取用户优惠券信息失败！UserCouponDaoImpl:getUserCouponList(String userId)", e);
		}

		return userCouponsList;
	}

}
